﻿namespace Mathematics.Expressions
{
    public abstract class MathExpression 
    {
        internal MathExpression()
        {

        }

        public abstract bool CanEvaluate();
        public abstract ExpressionValue Evaluate();

        public MathExpression Simplify()
        {
            var currentExpression = this;
            bool didReduce;
            do
            {
                currentExpression = currentExpression.Reduce(out didReduce);
            } while (didReduce);
            return currentExpression;
        }

        protected internal abstract MathExpression Reduce(out bool didReduce);
    }
}
